package dom;

import java.util.ArrayList;
import java.util.List;

/**
 * Student Account class
 * @author Alex Perkins
 */
public class StudentAccount {

	private String firstName;
	private String lastName;
	private String emailAddress;
	private String phoneNumber;
	private String username;
	private String password;
	private EducationalSystemEnum edu;
	private List<BookReservation> bookResevations;
	
	public StudentAccount(){
		bookResevations = new ArrayList<BookReservation>();
	}
	
	public StudentAccount(String username, String password){
		this.username = username;
		this.password = password;
		bookResevations = new ArrayList<BookReservation>();
	}
	
	public StudentAccount(String first, String last, String email, String phone, String username, String password, EducationalSystemEnum edu){
		this.firstName = first;
		this.lastName = last;
		this.emailAddress = email;
		this.phoneNumber = phone;
		this.username = username;
		this.password = password;
		this.edu = edu;
		bookResevations = new ArrayList<BookReservation>();
	}
	
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public String getEmailAddress() {
		return emailAddress;
	}
	public void setEmailAddress(String emailAddress) {
		this.emailAddress = emailAddress;
	}
	public String getPhoneNumber() {
		return phoneNumber;
	}
	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	public EducationalSystemEnum getEdu() {
		return edu;
	}

	public void setEdu(EducationalSystemEnum edu) {
		this.edu = edu;
	}

	public List<BookReservation> getBookResevations() {
		return bookResevations;
	}

	public void setBookResevations(List<BookReservation> bookResevations) {
		this.bookResevations = bookResevations;
	}
	
	public void addBookReservation(BookReservation bookReservation){
		if(this.bookResevations == null){
			this.bookResevations = new ArrayList<BookReservation>();
		}
		this.bookResevations.add(bookReservation);
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("[username='" + this.username + "', ");
		sb.append("firstName='" + this.firstName + "', ");
		sb.append("lastName='" + this.lastName + "', ");
		sb.append("email='" + this.emailAddress + "', ");
		sb.append("phone='" + this.phoneNumber + "']");
		return sb.toString();
	}

	@Override
	public boolean equals(Object obj) {
		StudentAccount sa = null;
		if(obj instanceof StudentAccount){
			sa = (StudentAccount) obj;
		}
		if(sa == null){
			System.out.println("Performing equals operation on a null/empty Student Account");
			return false;
		}
		if(sa.username.equalsIgnoreCase(this.username)){
			return true;
		}
		return false;
	}
	
}
